package main

import "fmt"

//父类
type Human struct{
    Name string
    Age int
}

func (this Human) Eat(){
    fmt.Println("Human Eat...")
}

func (this Human) Walk(){
    fmt.Println("Human Walk...")
}

//子类
type Man struct{
    Human       // 表示Man继承Human
    Level int
}

//覆盖父类方法
func (this Man) Eat(){
    fmt.Println("Man Eat...")
}

// 子类新方法
func (this Man) Fly(){
    fmt.Println("Man Fly...")
}

func (this Man) Print(){
    fmt.Println("name = ",this.Name)
    fmt.Println("age = ",this.Age)
    fmt.Println("Level = ",this.Level)
}

func main(){
    h := Human{"JackyChen",18}
    fmt.Printf("Human = %v\n",h)

    //m := Man{Human{"cxhblog",25},2}
    var m Man
    m.Name = "cxhblog"
    m.Age = 25
    m.Level = 3
    fmt.Printf("Man = %v\n",m)

    m.Eat()
    m.Fly()
    m.Print()
}